<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>职位管理</title>
    <link rel="shortcut icon" th:href="@{/img/favicon.ico}"/>
    <link rel="bookmark" th:href="@{/img/favicon.ico}" type="image/x-icon"/>
    <link th:href="@{/css/style.css}" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" th:src="@{/js/jquery.js}"></script>
    <script type="text/javascript">
        function tipOpen(content,num,chagestate) {
            $(".tipright p").text(content);
            $("#tip").fadeIn(200);

            $("#jobid").val(num);
            $("#chagestate").val(chagestate);
        }

        function tipClose() {
            $("#tip").fadeOut(200);

            var jobid = $("#jobid").val();
            var chagestate = $("#chagestate").val();

            location.href = "/erp1/sys/position/updatestate?id="+jobid+"&chagestate="+chagestate;

        }

        function tipClose2() {
            $("#tip").fadeOut(200);
        }
    </script>
</head>

<body>
<div class="place"><span>位置：</span>
    <ul class="placeul">
        <li><a th:href="@{/sys/users/userall}">系统管理</a></li>
        <li><a th:href="@{/sys/position/positionList}">职位管理</a></li>
    </ul>
</div>
<div class="rightinfo">
    <form th:action="@{/sys/position/positionList}" method="post" id="positionList">
        <input type="hidden" name="pageno" value="1" id="pageno"/>
        <ul class="tools">
            <li><label>职位名称:</label>
                <input type="text" name="jobName" th:value="${job.jobName}"/>
            </li>
            <li><label>所属部门：</label>
                <select name="jobDeptId">
                    <option value="0">请选择部门</option>
                    <option th:each="d : ${session.depts}" th:value="${d.deptId}" th:text="${d.deptName}"
                            th:selected="${d.deptId==job.jobDeptId?'true':'false'}"></option>
                </select>
            </li>
            <li class="subBut" onclick="goPage(1)"><img th:src="@{/images/t06.png}"/>查询</li>
            <li class="subBut" onclick="window.location.href='positionAdd.html'"><img src="../../images/t01.png"/>添加</li>
            <li class="subBut" onclick="reset()"><img th:src="@{/images/t03.png}"/>重置</li>
        </ul>
        <table class="tablelist">
            <thead>
            <tr>
                <th>序号</th>
                <th>职位</th>
                <th>所属部门</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <tr th:each="job:${jpInfo.list}">
                <td th:text="${job.jobId}">1</td>
                <td th:text="${job.jobName}">经理</td>
                <td th:text="${job.dept.deptName}">研发部</td>
                <td th:text="${job.jobState=='1'?'正常':'注销'}"></td>

                <td>
                    <a th:href="@{'/sys/position/goUpdate/'+${job.jobId}}" class="tablelink">修改</a>
                    <a th:href="@{'/sys/position/grantPage/'+${job.jobId}}" class="tablelink">赋权</a>

                    <input type="hidden" id="chagestate"/>
                    <input type="hidden" id="jobid"/>

                    <a href="javascript:void(0)" th:if="${job.jobState.equals('1')}" class="tablelink" th:onclick="@{'tipOpen(\'是否确认禁用此条信息？\','+${job.jobId}+',2)'}">禁用</a>
                    <a href="javascript:void(0)" th:if="${job.jobState.equals('2')}" class="tablelink" th:onclick="@{'tipOpen(\'是否确认启用此条信息？\','+${job.jobId}+',1)'}">启用</a>

                </td>
            </tr>

            </tbody>
        </table>
        <div class="pagin">
            <div class="message">共<i class="blue" th:text="${jpInfo.total}"></i>条记录，当前显示第&nbsp;<i class="blue" th:text="${jpInfo.pageNum}">2&nbsp;</i>页</div>
            <ul class="paginList">
                <li class="paginItem">
                    <a href="javascript:void(0);" th:onclick="goPage([[${jpInfo.isFirstPage?1:jpInfo.pageNum-1}]])">
                        <span th:class="${jpInfo.isFirstPage?'pagepre':'pagenxt roate'}"></span>
                    </a>
                </li>
                <li th:class="${page==jpInfo.pageNum?'paginItem current':'paginItem'}"
                    th:each="page : ${jpInfo.navigatepageNums}">
                    <a href="javascript:;"  th:text="${page}" th:onclick="goPage([[${page}]])">1</a>
                </li>
                <li class="paginItem">
                    <a href="javascript:void(0);" th:onclick="goPage([[${jpInfo.isLastPage?jpInfo.pages:jpInfo.pageNum+1}]])">
                        <span th:class="${jpInfo.isLastPage?'pagepre roate':'pagenxt'}"></span>
                    </a>
                </li>
            </ul>
        </div>
    </form>
    <!-- 提示框 -->
    <div id="tip" class="tip">
        <div class="tiptop"><span>提示信息</span><a onclick="tipClose()"></a></div>
        <div class="tipinfo"><span><img th:src="@{/images/ticon.png}"/></span>
            <div class="tipright">
                <p></p>
                <cite>如果是请点击确定按钮 ，否则请点取消。</cite></div>
        </div>
        <div class="tipbtn">
            <input name="" type="button" class="sure" value="确定" onclick="tipClose()"/>
            &nbsp;
            <input name="" type="button" class="cancel" value="取消" onclick="tipClose2()"/>
        </div>
    </div>
</div>
<script type="text/javascript">
    $('.tablelist tbody tr:odd').addClass('odd');
    function goPage(num) {
        // alert(num);
        $("#pageno").val(num);
        $("#positionList").submit();
    }

    function reset() {
        $("input[name=jobName]").val("");
        $("select[name=jobDeptId]>option:eq(0)").attr("selected","true");
    }
</script>
</body>
</html>
